package fisio.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import fisio.connection.ConnectionManager;

public class UtilDAO {

	private static final String SQL_CURRENT_DATE = "SELECT CURRENT_DATE()";
	
	public static java.sql.Date getDataHoje() {

		Connection conn = ConnectionManager.getConnection();
		java.sql.Date retorno = null;

		try {

			PreparedStatement stmt = conn.prepareStatement(SQL_CURRENT_DATE);
			
			ResultSet rs = stmt.executeQuery();
			if(rs.next()) {
				retorno = rs.getDate(1);
			}

			rs.close();
			stmt.close();
			conn.close();

		} catch(SQLException e) {
			System.out.println("\nERRO na consulta: "+e.getMessage());
		}

		return retorno;
	}
}
